package io.renren.modules.sys.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.InvoiceDao;
import io.renren.modules.sys.entity.InvoiceEntity;
import io.renren.modules.sys.service.InvoiceService;
import oracle.net.aso.a;


@Service("invoiceService")
public class InvoiceServiceImpl extends ServiceImpl<InvoiceDao, InvoiceEntity> implements InvoiceService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
    	Integer userId=null;
    	if(null!=params.get("userId")&&!StringUtils.isEmpty(params.get("userId").toString())) {
    		userId=Integer.valueOf(params.get("userId").toString());
    	}
    	String companyName=(String) params.get("companyName");
        Page<InvoiceEntity> page = this.selectPage(
                new Query<InvoiceEntity>(params).getPage(),
                new EntityWrapper<InvoiceEntity>()
                .addFilterIfNeed(null!=userId, "user_id={0}", userId)
                .like(!StringUtils.isEmpty(companyName), "company_name", companyName)
        );
        return new PageUtils(page);
    }

}
